﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AcademicPlanner.Framework.Helpers;

namespace AcademicPlanner.Presentation
{
	/// <summary>
	/// ControlModel is the base class for all model
	/// objects of <c>Control</c>s.
	/// </summary>
	/// <since>1.0</since>
	public class ControlModel
	{
		/// <summary>
		/// Gets or sets the html id of the control.
		/// </summary>
		/// <since>1.0</since>
		public string Id { get; set; }

		/// <summary>
		/// Gets or sets whether or not the control is embedded.
		/// </summary>
		/// <since>1.0</since>
		public bool IsSub { get; set; }
	}

	/// <summary>
	/// Control(TModel) is the base class for all strongly typed user controls in the AcademicPlanner application.
	/// It encapsulates common user control functionality such as translation of string messages.
	/// </summary>
	/// <typeparam name="TModel">The type of the model object of the strongly typed Control.</typeparam>
	/// <since>1.0</since>
	public class Control<TModel> : ViewUserControl<TModel> where TModel : ControlModel
    {
		/// <summary>
		/// Gets or sets the title of this Control.
		/// </summary>
		/// <since>1.0</since>
		public string Title { get; protected set; }

		/// <summary>
		/// Translates a string message from the application's source language to its current
		/// target language read from the session. This method is a convenience wrapper of
		/// <see cref="M:AcademicPlanner.Framework.Helpers.TranslationHelper.Translate"/> 
		/// for <code>Control</code> objects.
		/// </summary>
		/// <param name="pText">The message to translate.</param>
		/// <returns>The translated message.</returns>
		/// <seealso cref="M:AcademicPlanner.Framework.Helpers.TranslationHelper.Translate"/>
		/// <since>1.0</since>
		public static string Tr(string pText)
		{
			return TranslationHelper.Translate(pText, "Presentation");
		}
    }
}
